function createXHR(){
	
	if(window.ActiveXObject){
		
		xhrObject = new ActiveXObject("Microsoft.XMLHTTP");
		
	}else if(window.XMLHttpRequest){
		
		xhrObject = new XMLHttpRequest();
	}
}

function Ocheck(id){
	
	createXHR();
	
	var url = "Mem_Id="+id+"";
	var num = "num="+2+"";

	$.getJSON("./AdminExe.do?action_code=list&"+url+"&"+num,
	  
	 function(json){
	
		$("#aa").remove();
		$("#bb").remove();	
			
		for(var i = 0 ; i < json.conversion.length ; i++){
			$(".img").prepend("<div id='aa'><img src='/KOMORIUTA/Applications/Old/photo/"+json.conversion[i].old_photo+"'width='150'height='150'/></div>");
				
			$(".table").prepend("<div id='bb'><table width='240' border='1' cellspacing = '0' cellpadding = '0'>" +
						"<tr><td width='34%' height='30'><div align='center'>お名前</div></td><td width='66%'>"+json.conversion[i].mem_namek+"</td></tr>"+
						"<tr><td height='30'><div align='center'>フリガナ</div></td><td>"+json.conversion[i].mem_nameh+"</td></tr> " +
						"<tr><td height='30'><div align='center'>生年月日</div></td><td>"+json.conversion[i].mem_year+"年"+json.conversion[i].mem_month+"月"+json.conversion[i].mem_day+"日</td>"+
						"<tr><td height='30'><div align='center'>携帯電話</div></td><td>"+json.conversion[i].mem_mobile+"</td>" +
						"<tr><td height='30'><div align='center'>E-MAIL</div></td><td>"+json.conversion[i].mem_email+"</td></tr></table></div>");
				
			$("#Old_Add").val(json.conversion[i].old_add);
				
			if(json.conversion[i].old_gender == 0){
					$("#Old_Gender").val("男性");
			}else{
					$("#Old_Gender").val("女性");
			}
			$("#Old_Kind").val(json.conversion[i].old_kind);
			$("#Old_Money").val(json.conversion[i].old_money+"円");
			$("#Vvalue").val(json.conversion[i].Vvalue.replace(/,/g," "));
			$("#Dvalue").val(json.conversion[i].Dvalue.replace(/,/g," "));
			$("#memNick").val(json.conversion[i].mem_nick);
			$("#minho").val(json.conversion[i].members_id);
		}
		$(".left").toggle("fast");
		$(".field").toggle("fast");
		$("#minho").val();
		$("#memNick").val();
  });
}

function Ycheck(id){
	
	createXHR();
	
	var url = "Mem_Id="+id+"";
	var num = "num="+5+"";
	
	$.getJSON("./AdminExe.do?action_code=list&"+url+"&"+num,
	   
	 function(json){
	
		$("#aa").remove();
		$("#bb").remove();	
			
		for(var i = 0 ; i < json.conversion.length ; i++){
			$(".img").prepend("<div id='aa'><img src='/KOMORIUTA/Applications/Young/photo/"+json.conversion[i].bby_photo+"'width='150'height='150'/></div>");
			
			var table = "<div id='bb'><table width='240' border='1' cellspacing = '0' cellpadding = '0'>" +
			"<tr><td width='34%' height='30'><div align='center'>お名前</div></td><td width='66%'>"+json.conversion[i].mem_namek+"</td></tr>"+
			"<tr><td height='30'><div align='center'>フリガナ</div></td><td>"+json.conversion[i].mem_nameh+"</td></tr> " +
			"<tr><td height='30'><div align='center'>生年月日</div></td><td>"+json.conversion[i].mem_year+"年"+json.conversion[i].mem_month+"月"+json.conversion[i].mem_day+"日</td>"+
			"<tr><td height='30'><div align='center'>携帯電話</div></td><td>"+json.conversion[i].mem_mobile+"</td>" +
			"<tr><td height='30'><div align='center'>お子さんの情報</div></td><td>";
			
			var childs = json.conversion[i].cid.split(",");
			
			for( index = 0; index < childs.length-1 ; index++ ){
				var num = index + 1;
				table += '<a class="black" href="javascript:childecheck('+childs[index]+')"' + '>'+ num + '</a>';
			}	

			table += "</td></tr></table></div>";
			$(".table").prepend(table);
				
			$("#Bbp_Contents").val(json.conversion[i].bby_contents);
			$("#Bby_Add").val(json.conversion[i].bby_add);
				
			if(json.conversion[i].bby_gender == 0){
					$("#Bby_Gender").val("男性");
			}else{
					$("#Bby_Gender").val("女性");
			}
			$("#Bby_Kind").val(json.conversion[i].bby_kind);
			$("#Vvalue").val(json.conversion[i].vvalue.replace(/,/g," "));
			$("#Dvalue").val(json.conversion[i].dvalue.replace(/,/g," "));
			$("#minho").val(json.conversion[i].members_id);
			$("#memNick").val(json.conversion[i].memnick);
		}
		$(".left").toggle("fast");
		$(".field").toggle("fast");
		$("#minho").val();
		$("#memNick").val();
  });
}


function childecheck(id){
	
	createXHR();
	
	var url = "cid="+id+"";
	var num = "num="+6+"";
	
	$.getJSON("./AdminExe.do?action_code=list&"+url+"&"+num,
	   
	 function(json){
		
		$("#cc").remove();
		$("#dd").remove();
		
		for(var i = 0 ; i < json.conversion.length ; i++){
		
			if(json.conversion[i].bbp_gender == 0){
				
				var gender = '男性';
			}else {
			
				var gender = '女性';
			}
			
		$(".Yimg").prepend("<div id='cc'><img src='/KOMORIUTA/Applications/Young/photo/"+json.conversion[i].bbp_photo+"'width='150'height='150'/></div>");
		
	
		var table = "<div id='dd'><table width='240' border='1' cellspacing = '0' cellpadding = '0'>" +
				"<tr><td width='34%' height='30'><div align='center'>お名前</div></td><td width='66%'>"+json.conversion[i].bbp_namek+"</td></tr>"+
				"<tr><td height='30'><div align='center'>フリガナ</div></td><td>"+json.conversion[i].bbp_nameh+"</td></tr> " +
				"<tr><td height='30'><div align='center'>生年月日</div></td><td>"+json.conversion[i].bbp_birth+"</td></tr>"+
				"<tr><td height='30'><div align='center'>性別</div></td><td>"+gender+"</td></tr></table></div>";
		
				$(".Ytable").prepend(table);
	
	};
	$(".Yleft").toggle("fast");
	
});
}

function finalmapping(id){
	createXHR();
	
	var url = "mid="+id+"";
	var num = "num="+4+"";
	
	$.getJSON("./AdminExe.do?action_code=FinalAcept&"+url+"&"+num,
			   
			 function(json){
		
		$("#dd").remove();
		$("#cc").remove();
		
		for(var i = 0 ; i < json.conversion.length ; i++){
			
			var table = "<div id='dd'><table width='100%' border='1' cellspacing = '2' cellpadding = '4'>" +
			
			"<tr><td width='32%'align='center' rowspan='12' valign='top'><img src='/KOMORIUTA/Applications/Young/photo/"+json.conversion[i].bby_photo+"'width='145' height='145'/></td>"+
			
			"<tr><td width='18%'>お名前</td><td>"+json.conversion[i].mem_namek+"(若い夫婦の側)</td></tr>"+
			
			"<tr><td>E-MAIL</td><td>"+json.conversion[i].mem_email+"</td></tr>"+
			
			"<tr><td>ADDRESS</td><td>"+json.conversion[i].mem_add1+""+json.conversion[i].mem_add2+"</td></tr>"+
			
			"<tr><td>お宅の電話</td><td>"+json.conversion[i].mem_phone+"</td></tr>"+
			
			"<tr><td>携帯電話</td><td>"+json.conversion[i].mem_mobile+"</td></tr></table></div>"+
			
			
			"<div id='cc'><table width='100%' border='1' cellspacing='2' cellpadding = '4'>"+
			
			"<tr><td width='32%'align='center' rowspan='6' valign='top'><img src='/KOMORIUTA/Applications/Old/photo/"+json.conversion[i].old_photo+"'width='145' height='145'/></td>"+
			
			"<tr><td width='18%'>お名前</td><td>"+json.conversion[i].mem_namekO+"(中高年の側)</td></tr>"+
			
			"<tr><td>E-MAIL</td><td>"+json.conversion[i].mem_emailO+"</td></tr>"+
			
			"<tr><td>ADDRESS</td><td>"+json.conversion[i].mem_add1O+""+json.conversion[i].mem_add2O+"</td></tr>"+
			
			"<tr><td>お宅の電話</td><td>"+json.conversion[i].mem_phoneO+"</td></tr>"+
			
			"<tr><td>携帯電話</td><td>"+json.conversion[i].mem_mobileO+"</td></tr></table></div>";
			
			$(".final").prepend(table);
		}
		$(".final").toggle("fast");	
			
	});
}

function finalcheck(id){  //접수신청완료된 부모(희망정보)!!
	
	createXHR();
	
	var url = "mid="+id+"";
	var num = "num="+2+"";
	
	$.getJSON("./AdminExe.do?action_code=FinalAcept&"+url+"&"+num,
	   
	 function(json){
		
	$("#dd").remove();
	$("#cc").remove();	
		for(var i = 0 ; i < json.conversion.length ; i++){
			
			if(json.conversion[i].bby_gender == 0){
				
				var gender = '男性';
			
			}else {
			
				var gender = '女性';
			}
			
	var table = "<div id='dd'><form id='finalcheck' method='post' action='/KOMORIUTA/AdminExe.do?action_code=FinalAcept&num="+3+"'>"+
			
			"<input type='hidden' name='bby_gender' value='"+json.conversion[i].bby_gender+"'/>"+
			"<input type='hidden' name='bby_add' value='"+json.conversion[i].bby_add+"'/>"+
			"<input type='hidden' name='bby_kind' value='"+json.conversion[i].bby_kind+"'/>"+
			"<input type='hidden' name='bby_money' value='"+json.conversion[i].bby_money+"'/>"+
			"<input type='hidden' name='memid' value='"+json.conversion[i].members_id+"'/>"+
			"<input type='hidden' name='Mem_Nick' value='"+json.conversion[i].members_nick+"'/>"+
			
			"<table width='100%' border='1' cellspacing = '2' cellpadding = '4'>" +
			
			"<tr><td width='32%'align='center' rowspan='8' valign='top'><img src='/KOMORIUTA/Applications/Young/photo/"+json.conversion[i].bby_photo+"'width='145' height='230'/></td>"+
			
			"<td width='23%'>性別</td><td width='45%'>"+gender+"</td></tr>"+
			
			"<tr><td>ADDRESS</td><td>"+json.conversion[i].bby_add+"</td></tr>"+
			
			"<tr><td>お宅の電話</td><td>"+json.conversion[i].mem_phone+"</td></tr>"+
			
			"<tr><td>携帯電話</td><td>"+json.conversion[i].mem_mobile+"</td></tr>"+
			
			"<tr><td>ご希望の保育</td><td>"+json.conversion[i].bby_kind+"</td></tr>"+
			
			"<tr><td>ご希望の資格</td><td>"+json.conversion[i].vvalue.replace(/,/g," ")+"</td></tr>"+
			
			"<tr><td>ご希望の曜日</td><td>"+json.conversion[i].dvalue.replace(/,/g," ")+"</td></tr>"+
			
			"<tr><td>ご希望の支給</td><td>"+json.conversion[i].bby_money+"</td></tr></table></form><br/>"+
		
			"<a href='javascript:finalmap();'class='black'>検索</a>";
			
			
			$(".final").prepend(table);
		}
		$(".final").toggle("fast");	
});
	
}

function finalmap(){  //최종맵핑시키는구간!!
	
	
	$("#finalcheck").submit();
	
}


function Osubmit(){
	
	var id = $("#minho").val();
	var nick  = $("#memNick").val();
	
	location.href="/KOMORIUTA/AdminExe.do?action_code=list&nick="+nick+"&num=3&id="+id+"&page=1";
	
	
}

function Ysubmit(){
	
	var id = $("#minho").val();
	var nick = $("#memNick").val();
	
	location.href="/KOMORIUTA/AdminExe.do?action_code=list&nick="+nick+"&num=7&id="+id+"&page=1";

}


function yeargo(level){
	
	var check = level;
	if(check == "old"){
		
		$("#yeargo").submit();
	}else if(check == "young"){
		
		$("#yeargoY").submit();
	}
}

function monthgo(level){
	var check = level;
	
	if(check == "old"){
		
		$("#yeargom").submit();
		
	}else if(check == "young"){
		
		$("#yeargomY").submit();
	}
	
}

function yearRecgo(level){ /*접수현황 통계 */
	
	var check = level;
	
		if(check == "old"){ //할아버지(년별) 접수통계 가기!!
			$("#yeargo").submit();
		}else if(check == "young"){//젊은이(년별)  접수통계가기!!
			$("#yeargoY").submit();
		}
}

function monthRecgo(level){
	var check = level;
	
	if(check == "old"){ //할아버지(월별) 접수통계 가기!!
		
		$("#yeargom").submit();
	}else if(check == "young"){
		//젊은이(월별)  접수통계가기!!
		$("#yeargomY").submit();
	}
	
}

function doList(page){
	$("#currentPage").val(page);
	$("#people").submit();
}

function delet(id){
	
	var age = $("#age").val();
	location.href="/KOMORIUTA/AdminMem.do?action_code=delet&id="+id+"&age="+age;

}
function business(id){
	
	createXHR();

	$.get("/KOMORIUTA/AdminMem.do?action_code=business&id=" + id , function(data) {
		
		 var result = $(data).find("result").text();
			$(".result").remove();
			$("#table").prepend("<table id='"+id+"' width='298px' border='1' cellspacing='0' cellpadding='0' class='result'>" +
										"<tr>" +
										"<td height='40' align='center' scope='col'>mapping相手</td>" +
										"</tr>" +
			 							"<tr>" +
			 							"<td align='center' height='30'>"+result+"</td>" +
			 							"</tr>" +
			 					"</table>");
			$("#"+id).toggle("normal");

	}); 
	
}
function mypage(id){
	var valu;
	createXHR();
	$.getJSON("/KOMORIUTA/AdminMem.do?action_code=mypage&id=" + id , function(data) {
		
		if(data.val == "no"){
			valu="共有者の承認を待っています。";
		}else{
			valu="問題ない。";
		}
		// alert("공유자 = " + data.share + " || 공유자 상태 = " + data.val);
		$(".result").remove();
		$("#table").prepend("<table id='"+id+"' width='298px' border='1' cellspacing='0' cellpadding='0' class='result'>" +
									"<tr>" +
									"<td width='115px' height='40' align='center' scope='col'>共有者</td>" +
									"<td width='183px' align='center' scope='col'>状態</td>" +
									"</tr>" +
		 							"<tr>" +
		 							"<td align='center' height='30'>"+data.share+"</td>" +
		 							"<td align='center'>"+valu+"</td>" +
		 							"</tr>" +
		 					"</table>");
		$("#"+id).toggle("normal");
	}); 
	
}

function oldMypage(id, nick){
	var valu;
	createXHR();
	$.getJSON("/KOMORIUTA/AdminMem.do?action_code=oldmypage&nick=" + nick , function(data) {
		
		if(data.val == "no"){
			valu="共有承認を待っています。";
		}else{
			valu="問題ない。";
		}
		// alert("제작자 = " + data.share + " || 지금 상태 = " + data.val);
		$(".result").remove();
		$("#table").prepend("<table id='"+id+"' width='298px' border='1' cellspacing='0' cellpadding='0' class='result'>" +
									"<tr>" +
									"<td width='115px' height='40' align='center' scope='col'>共有者</td>" +
									"<td width='183px' align='center' scope='col'>状態</td>" +
									"</tr>" +
		 							"<tr>" +
		 							"<td align='center' height='30'>"+data.share+"</td>" +
		 							"<td align='center'>"+valu+"</td>" +
		 							"</tr>" +
		 					"</table>");
		$("#"+id).toggle("normal");
	}); 
	
}

function change(select){
	var selectval = ($("#search > option:selected").val());
	
	if(selectval == "id"){
		$(".area").remove();
		$("#input").prepend("<input type='text' class='area' name='searchword' />");
		
	}else if(selectval == "check"){
		$(".area").remove();
		$("#input").prepend("<select name='checkvalue' class='area'>" +
				"<option value='1'>受付 待機</option>" +
				"<option value='2'>受付 取り消す</option>" +
				"<option value='3'>承認待機</option>" +
				"<option value='5'>受付成立</option>" +
				"</select>");
		
	}else if(selectval == "mypage"){
		$(".area").remove();
		$("#input").prepend("<select name='mypagevalue' class='area'>" +
				"<option value='no'>-無-</option>" +
				"<option value='yes'>-運営中-</option>" +
				"</select>");
		
	}else if(selectval == "all"){
		$(".area").remove();
	}
}


function finalacept(){
	
	$("#mapfinal").toggle("normal");

}
//<form id="mapfinal" method="post" action="/KOMORIUTA/ApplicationsOld.do?action_code=mapfinal ">
function megacheck(){
	
	$("#mapworld").submit();
}

function offline(id){
	
	var mid = "&mid="+id+"";
	
	location.href="/KOMORIUTA/ApplicationsOld.do?action_code=mapfinal&fcheck=2"+mid;
	
	//$("#mapworld").submit();
	
}

function offlinefail(id){
	
	var mid = "&mid="+id+"";
	
	location.href="/KOMORIUTA/ApplicationsOld.do?action_code=mapfinal&fcheck=1"+mid;
}

function success(id){
	
	var num = "&id="+id+"";
	
	location.href="/KOMORIUTA/ApplicationsOld.do?action_code=success&check=2"+num;
	
}

function disable(id){
	
	var num = "&id="+id+"";
	var check = "&check="+2+"";
	
	location.href="/KOMORIUTA/ApplicationsOld.do?action_code=disable"+check+"&id="+id;
	
}
function mappingList(){
	location.href="/KOMORIUTA/AdminCheck.do?action=mappinglist";
}

function mappingMember(old, young){
	window.open("/KOMORIUTA/AdminCheck.do?action=mappingmember&old=" + old + "&young=" + young, "_blank", ",location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=100,top=200, width=1100");
}


function mappingDelet(old, young){
	location.href="/KOMORIUTA/AdminCheck.do?action=mappingdelet&old=" + old + "&young=" + young;
}
